package com.xxh.dasongapp.security.controller;
import com.xxh.dasongapp.common.Result;
import com.xxh.dasongapp.common.entity.User;
import com.xxh.dasongapp.security.common.param.LoginPARAM;
import com.xxh.dasongapp.security.common.param.WxLoginPARAM;
import com.xxh.dasongapp.security.service.LoginService;
import com.xxh.dasongapp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/login")
@Api(tags = "登录接口")
@Slf4j
public class LoginController {

    @Autowired
    LoginService loginService;

    @Autowired
    UserService userService;
    @Autowired
    PasswordEncoder passwordEncoder;

    @ApiOperation(value = "用户表单登录")
    @PostMapping("/formlogin")
    public Result<?> userLogin(@RequestBody LoginPARAM loginPARAM){
        return loginService.login(loginPARAM);
    }

    @ApiOperation(value = "小程序授权登录")
    @PostMapping("/wxlogin")
    public Result<?> wxLogin(@RequestBody WxLoginPARAM wxLoginPARAM){
        return loginService.wxlogin(wxLoginPARAM);
    }
    
}
